﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body class="easyui-layout">

    <link href="../hcjsui/jquery-easyui-1.3.3/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../hcjsui/jquery-easyui-1.3.3/themes/icon.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" rev="stylesheet" type="text/css" href="../hcjsui/Styles/usbocx.css" />
    <style type="text/css">
        body {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            background-color: #EEF2FB;
        }

        .gridRow {
            width: 500px;
        }
    </style>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="../hcjsui/jquery-easyui-1.3.3/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../hcjsui/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js" charset="utf-8" type="text/javascript"></script>
    <script src="../hcjsui/Scripts/jquery.form.js" type="text/javascript"></script>
    <script src="../hcjsui/js/json2.js" type="text/javascript"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script src="../hcjsui/js/customer.js" type="text/javascript"></script>
    <script type="text/javascript" src="../hcjsui/js/usbocx.js"></script>
    <script src="../hcjsui/Scripts/jquery.validate.js" type="text/javascript"></script>
    <script src="../hcjsui/js/easyui-extend/form.js" type="text/javascript"></script>
    <script src="../hcjsui/js/easyui-extend/window.js" type="text/javascript"></script>
    <script src="../hcjsui/js/validateExtends.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hc.js"></script>
    <div region="north" title="菜单管理" split="false" border="false" style="height: 60px;">
        <table width="98%">
            <tr>
                <td class="auto-style1">
                    <form id="searchForm" method="post" runat="server">
                        <div>
                            名称：<input id="findname" name="findname" />
                            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="javascript:Search();">查询</a>&nbsp;&nbsp;<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="javascript:Reset();">重置</a>
                        </div>
                    </form>
                </td>


            </tr>
        </table>
    </div>
    <div id="divfortoolbar" style="text-align: right;">
        <a href="#" class="easyui-linkbutton" onclick="javascript:Add();">增加</a>&nbsp;&nbsp; 
        <a href="#" class="easyui-linkbutton" onclick="javascript:Delete();">删除</a>

    </div>
    <div region="center" title="菜单列表" style="padding: 0px;" border="false">

        <table id="grid1"></table>

    </div>
    <div id="itemEditContainer" class="easyui-window" title="信息管理" data-options="iconCls:'icon-save',closed:'true'" style="width: 550px; height: 400px">
        <div>
            <div class="edititemblock" style="padding: 5px 5px 5px 5px; font-size: 15px;">
                <form id="itemEdit" name="itemEdit" method="post" action="../ashx/sp.ashx">
                    <input type="hidden" class="actionValue" id="editAction" name="action" value="" />
                    <input type="hidden" id="id" name="id" />
                    <input type="hidden" id="tablename" name="tablename" value="" />
                    <input type="hidden" id="tablemidname" name="tablemidname" value="" />
                    <table cellpadding="5px">
                        <tr>
                            <td>类型：</td>
                            <td>
                                <select id="fisroot" name="fisroot" style="width: 150px;">
                                    <option value="是">主菜单</option>
                                    <option value="否" selected="selected">子菜单</option>

                                </select>
                            </td>
                            <td>主编号：</td>
                            <td>
                                <input type='text' id='ftabid' name='ftabid' class="easyui-validatebox" missingmessage="少于2个字符" validtype="length[0,2]" />
                            </td>
                        </tr>
                        <tr>
                            <td>菜单名称：</td>
                            <td>
                                <input type='text' id='fname' name='fname' /></td>
                            <td>菜单编码：</td>
                            <td>
                                <input type='text' id='fdescription' name='fdescription' /></td>
                        </tr>
                        <tr>



                            <td>子编号：</td>
                            <td>
                                <input type='text' id='findexid' name='findexid' class="easyui-validatebox" missingmessage="少于2个字符" validtype="length[0,2]" />
                            </td>
                            <td>图标：</td>
                            <td>
                                <select id="ffshowimg" name="ffshowimg" style="width: 150px;">
                                    <option value="&#xe61d;" selected="selected">管理</option>
                                    <option value="&#xe668;">表情</option>
                                    <option value="&#xe656;">微笑</option>
                                    <option value="&#xe659;">耍酷</option>
                                    <option value="&#xe625;">Home</option>
                                    <option value="&#xe613;">图片</option>
                                    <option value="&#xe616;">新闻</option>
                                    <option value="&#xe60f;">音乐</option>
                                    <option value="&#xe62e;">系统</option>
                                    <option value="&#xe633;">帮助</option>
                                    <option value="&#xe60e;">锁定</option>
                                    <option value="&#xe605;">解锁</option>
                                    <option value="&#xe634;">出库</option>
                                    <option value="&#xe681;">分类</option>
                                    <option value="&#xe639;">合同</option>
                                    <option value="&#xe637;">任务</option>
                                    <option value="&#xe691;">问题反馈</option>
                                    <option value="&#xe692;">意见反馈</option>
                                    <option value="&#xe623;">日志</option>
                                    <option value="&#xe62c;">用户</option>
                                    <option value="&#xe643;">公司</option>
                                    <option value="&#xe611;">群组</option>
                                    <option value="&#xe61e;">数据统计</option>
                                    <option value="&#xe618;">柱状统计</option>
                                    <option value="&#xe643;">公司</option>
                                     <option value="&#xe669;">物流</option>
                                     <option value="&#xe6bb;">礼物</option>
                                      <option value="&#xe681;">分类</option>
                                     <option value="&#xe6d0;">客服</option>
                                     <option value="&#xe6cf;">排行榜</option>
                                </select></td>
                        </tr>


                        <tr>
                            <td>URL：</td>
                            <td colspan="3">
                                <input type='text' id='furl' name='furl' /></td>

                        </tr>

                        <tr>
                            <td colspan="4" align="center"><a class="easyui-linkbutton btn-save" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:editSubmit();">保存</a>
                                <a class="easyui-linkbutton btn-cancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#itemEdit')[0].reset();">重置</a></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <div id="div_bt" class="easyui-window" title="按钮管理" data-options="iconCls:'icon-save',closed:'true'" style="width: 550px; height: 300px">
        <div class="edititemblock" style="padding: 5px 5px 5px 5px; font-size: 15px;">
            <form id="form_bt" name="form_bt" method="post" action="../ashx/sp.ashx">
                <input type="hidden" class="actionValue" id="form_bt_action" name="action" value="" />
                <input type="hidden" id="form_bt_id" name="id" />
                <input type="hidden" id="form_bt_tablename" name="tablename" value="sysButton" />
                <input type="hidden" id="form_bt_tablemidname" name="tablemidname" value="BtnID" />
                <input type="hidden" id="fTabMenuId" name="fTabMenuId" />
                <table cellpadding="5px">
                    <tr>

                        <td>名称：</td>
                        <td>
                            <input type='text' id='fBtnText' name='fBtnText' class='easyui-validatebox' missingmessage='必须填写' required='true' />
                        </td>
                        <td>对应事件：</td>
                        <td>
                            <input type='text' id='fBtnIDHtml' name='fBtnIDHtml' />
                            <select id="selBtnIDHtml" name="selBtnIDHtml" class="easyui-combobox" style="width: 150px;">
                                <option value="" selected="selected"></option>
                                <option value="toolAdd">新增</option>
                                <option value="toolUpdate">修改</option>
                                <option value="toolDelete">删除</option>
                                <option value="toolImport">导入</option>
                                <option value="toolExport">导出</option>
                                <option value="toolConfirm">提交</option>
                                <option value="toolBack">打回</option>
                                <option value="toolCancel">取消</option>
                                <option value="toolSearch">查看</option>
                            </select>
                        </td>

                    </tr>

                    <tr>

                        <td>图标：</td>
                        <td>
                            <select id="fBtnIcon" name="fBtnIcon" class="easyui-combobox" style="width: 150px;" class='easyui-validatebox' missingmessage='必须填写' required='true'>
                                <option value="&#xe600;" selected="selected">新增Code</option>
                                <option value="&#xe6df;">修改Code</option>
                                <option value="&#xe6e2;">删除Code</option>
                                <option value="icon-add">新增</option>
                                <option value="icon-edit">修改</option>
                                <option value="icon-delete">删除</option>
                                <option value="icon-import">导入</option>
                                <option value="icon-export">导出</option>
                                <option value="icon-upload">上传文件</option>
                                <option value="icon-download">下载文件</option>
                                <option value="icon-confirm">提交</option>
                                <option value="icon-workflowback">打回</option>
                                <option value="icon-cancle">取消</option>
                                <option value="icon-search">查看</option>
                                <option value="notoolbaraccess">非工具栏权限</option>
                            </select>
                        </td>

                        <td>排序：</td>
                        <td>
                            <input type='text' id='fBtnNo' name='fBtnNo' value="0" class='easyui-validatebox' missingmessage='必须填写' required='true' />
                        </td>

                    </tr>



                    <tr>
                        <td colspan="4" align="center"><a class="easyui-linkbutton btn-save" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onclick="javascript:editSubmitBt();">保存</a>
                            <a class="easyui-linkbutton btn-cancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="javascript:$('#itemEdit')[0].reset();">重置</a></td>
                    </tr>
                </table>
            </form>
        </div>

    </div>
    <script type="text/javascript">
        spsetBase("sysTab", "pkid", "sysTab as T", "*", "#grid1", "uiaccess");
        $(function () {

            BindGrid();

            $("#tablename").val(pTableName);
            $("#tablemidname").val(pTableIdName);

            $('#ftype').change(function () {
                if ($(this).children('option:selected').val() != "银行")
                { $("#fparentId").removeAttr("disabled"); }
                else

                {
                    $("#fparentId").attr("disabled", "disabled");
                    $("#fparentId").val("");
                }
                // alert($(this).children('option:selected').val());
            });
        });



        var urltree = sposelTreeUrl("View_menu_bt as T", "id as ID,c_menuname  as ShowInfo,accesstype as ShowInfo2,T.ParentId,iconCls");


        urltree = urltree + "&sporderby=c_menuid";


        function BindGrid() {
            $(grid1ID).treegrid({
                url: urltree,
                idField: 'id',
                treeField: 'text',
                rownumbers: true,
                //toolbar: ptoolbar.length == 0 ? null : ptoolbar,
                toolbar:
        [
            { id: 'btnAdd', text: '新增', iconCls: 'icon-add', handler: toolAdd },
            { id: 'btnDel', text: '删除', iconCls: 'icon-delete', handler: toolDelete }
        ],
                columns: [[
                           { field: 'text', title: '名称', width: 250 },
                           { field: 'ShowInfo2', title: '类型', width: 250 },
               {
                   field: "y", title: "操作", align: "center", formatter: function (value, row, index) {
                       if (row.ShowInfo2 == "菜单") {
                           if (row.ParentId == "0") {
                               return "<a href='#' style='color: #369591;' onclick='javascript:Update(" + row.id + ")'>修改</a>";
                           }
                           else { return "<a href='#' style='color: #369591;' onclick='javascript:Update(" + row.id + ")'>修改</a>    <a href='#' style='color: #369591;' onclick='javascript:uiaccess_delete(" + row.id + ")'>删除</a>     <a href='#' style='color: #369591;' onclick='javascript:AddNewBt(" + row.id + ")'>新增按钮</a>"; }
                       }
                       else if (row.ShowInfo2 == "按钮")
                           return "<a href='#' style='color: #369591;' onclick='javascript:UpdateBt(" + row.id + ")'>修改</a>     <a href='#' style='color: #369591;' onclick='javascript:DelBt(" + row.id + ")'>删除</a>";
                   }
               }

                ]],
                onLoadSuccess: function (data) {

                },
                onBeforeLoad: function (param) {

                }
            });



            $("#selBtnIDHtml").combobox({
                onChange: function (newValue, oldValue) {
                    $("#fBtnIDHtml").val(newValue);
                }
            });
        }

        function Search() {
            $(grid1).datagrid("load");
        }

        function Reset() {

            $("#finddename").val("");
        }


        function UpdateBt(id) {
            $("#form_bt_action").val(CallBackCommand.Update);
            $("#form_bt_id").val(id);
            //方法2从数据库中找出(内容不在列表时)
            {
                $.get(sposelUrlByF("*", "sysButton as T", "BtnID=" + id, "", "", ""), //"../ashx/sp.ashx?action=GetTableObjINFO&talbename=sysButton as T&midname=BtnID&midvalue=" + id,
                    function (data) {
                        var data = JSON.parse(data);
                        if (data.message == JsonResult.Success) {
                            for (var i = 0; i < data.data.length; i++) {
                                var infoobj = data.data[i];
                                for (var filedname in infoobj) {
                                    var gethtmlf = $("#f" + filedname);
                                    if (gethtmlf && gethtmlf.length == 1) {
                                        var classname = gethtmlf.attr("class");
                                        if (classname == null || classname == 'undefined') {
                                            gethtmlf.val(infoobj[filedname]);
                                        }
                                        else if (classname.indexOf('-combobox') >= 0) {
                                            gethtmlf.combobox('setValue', infoobj[filedname]);
                                        }
                                        else if (classname.indexOf('-combotree') >= 0) {
                                            gethtmlf.combotree('setValue', infoobj[filedname]);
                                        }
                                        else if (classname.indexOf('-datebox') >= 0 || classname.indexOf('-datetimebox') >= 0) {
                                            gethtmlf.datebox('setValue', infoobj[filedname]);
                                        }
                                        else { gethtmlf.val(infoobj[filedname]); }
                                    }
                                }
                                break;
                            }
                        }
                        else {
                            $.messager.show({
                                title: '查找出错',
                                msg: data.data,
                                showType: 'show'
                            });
                        }


                    });
            }


            $('#div_bt').window({ title: "修改信息" });
            $("#div_bt").window("open");
        }

        function Update(id) {
            $("#editAction").val(CallBackCommand.Update);
            $("#id").val(id);
            //方法2从数据库中找出(内容不在列表时)
            {
                $.get(spselrowUrl(id),//"../ashx/sp.ashx?action=GetTableObjINFO&talbename=" + pTableName + "&midname=" + pTableIdName + "&midvalue=" + id,
                    function (data) {
                        var data = JSON.parse(data);
                        if (data.message == JsonResult.Success) {
                            for (var i = 0; i < data.data.length; i++) {
                                var infoobj = data.data[i];
                                for (var filedname in infoobj) {
                                    var gethtmlf = $("#f" + filedname);
                                    if (gethtmlf && gethtmlf.length == 1) {
                                        if (filedname.substring(0, 2) == "dt")
                                        { gethtmlf.datebox('setValue', infoobj[filedname]); }
                                        else
                                        { gethtmlf.val(infoobj[filedname]); }
                                    }
                                }
                                break;
                            }
                        }
                        else {
                            $.messager.show({
                                title: '查找出错',
                                msg: data.data,
                                showType: 'show'
                            });
                        }


                    });
            }


            $('#itemEditContainer').window({ title: "修改信息" });
            $("#itemEditContainer").window("open");
        }

        function DelBt(id) {

            $.messager.confirm("提示信息", "确定删除所选数据？", function (r) {
                if (!r) {
                    return;
                }
                ID = id;
                $.get(spodelUrl("sysButton", "BtnID", ID),

                function (data) {
                    var data = JSON.parse(data);
                    switch (data.message) {
                        case JsonResult.SessionOut:
                            $.messager.alert('系统出错', ' 登录超时，请重新登录!');
                            break;
                        case JsonResult.Error:
                            $.messager.alert('系统出错', data.data);
                            break;
                        case JsonResult.Success:
                            $.messager.show({
                                title: '提示信息',
                                msg: data.data,
                                showType: 'show'
                            });
                            $(grid1ID).treegrid("reload");
                            break;
                    }
                });
            });

        }
        function uiaccess_delete(ID) {

            {
                $.messager.confirm("提示信息", "确定删除所选数据？", function (r) {
                    if (!r) {
                        return;
                    }
                    $.get(spdelUrl(ID),//"../ashx/sp.ashx?action=del&tablename=" + pTableName + "&tablemidname=" + pTableIdName + "&id=" + ID,
                    function (data) {
                        var data = JSON.parse(data);
                        switch (data.message) {
                            case JsonResult.SessionOut:
                                $.messager.alert('系统出错', ' 登录超时，请重新登录!');
                                break;
                            case JsonResult.Error:
                                $.messager.alert('系统出错', data.data);
                                break;
                            case JsonResult.Success:
                                $.messager.show({
                                    title: '提示信息',
                                    msg: data.data,
                                    showType: 'show'
                                });
                                $(grid1ID).treegrid("reload");
                                break;
                        }
                    });
                });
            }
        }

        function toolAdd() {
            $('#itemEdit')[0].reset();
            $("#editAction").val(CallBackCommand.Inseart);
            $('#itemEditContainer').window({ title: "新增信息" });
            $("#itemEditContainer").window("open");
        }
        function AddNewBt(id) {
            $('#form_bt')[0].reset();
            $("#form_bt_action").val(CallBackCommand.Inseart);
            $("#fTabMenuId").val(id);
            $('#div_bt').window({ title: "新增按钮" });
            $("#div_bt").window("open");
        }
        function editSubmitBt() {
            $("#form_bt_tablename").val("sysButton");
            $("#form_bt_tablemidname").val("BtnID");
            if (!$("#form_bt").form('validate'))
            { return; }

            $('#form_bt').ajaxSubmit(function (message) {
                var data = JSON.parse(message);
                if (data.message == JsonResult.Success) {
                    $('#div_bt').window('close');
                    $.messager.show({
                        title: '消息',
                        msg: '信息提交成功',
                        showType: 'show'
                    });
                    $(grid1ID).treegrid("reload");
                }
                else {
                    $.messager.show({
                        title: '提交出错',
                        msg: data.data,
                        showType: 'show'
                    });
                }

            });

        }
        function editSubmit() {
            $("#tablename").val(pTableName);
            $("#tablemidname").val(pTableIdName);
            if (!$("#itemEdit").form('validate'))
            { return; }
            $('#furl').val(replaceAll2($('#furl').val(), "\\", "/"));
            $('#itemEdit').ajaxSubmit(function (message) {
                var data = JSON.parse(message);
                if (data.message == JsonResult.Success) {
                    $('#itemEditContainer').window('close');
                    $.messager.show({
                        title: '消息',
                        msg: '信息提交成功',
                        showType: 'show'
                    });
                    $(grid1ID).treegrid("reload");
                }
                else {
                    $.messager.show({
                        title: '提交出错',
                        msg: data.data,
                        showType: 'show'
                    });
                }

            });

        }

    </script>
</body>
</html>
